package com.me.control;

import java.util.ArrayList;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.audio.Sound;

public class SoundManager {
	
	private static ArrayList<Sound> arraySound;
	
//	public static int PLAY_MUSIC = 0;
	public static int START_GAME_SOUND = 0;
	public static int TOUCH_SCREEN_SOUND = 1;
	public static int TOUCH_MOVEOBJ_SOUND = 2;
//	public static int TOUCH_BOMB_SOUND = 3;
	public static int END_GAME_SOUND = 3;
	
	private static Music play_music;
	Sound start_game_sound;
	Sound touch_scr_sound;
	Sound touch_moveObj_sound;
//	Sound touch_bomb_sound;
	Sound end_game_sound;
	
	public SoundManager() {
		super();
		initSound();
		initMusic();
	}
	
	private void initSound(){
		start_game_sound = Gdx.audio.newSound(Gdx.files.internal("sound/startGame.ogg"));
		touch_scr_sound = Gdx.audio.newSound(Gdx.files.internal("sound/touchScreen.ogg"));
		touch_moveObj_sound = Gdx.audio.newSound(Gdx.files.internal("sound/touchMoveObj.mp3"));
//		touch_bomb_sound = Gdx.audio.newSound(Gdx.files.internal("sound/touchBomb.ogg"));
		end_game_sound = Gdx.audio.newSound(Gdx.files.internal("sound/endGame.mp3"));

		arraySound = new ArrayList<Sound>(4);
		arraySound.add(start_game_sound);
		arraySound.add(touch_scr_sound);
		arraySound.add(touch_moveObj_sound);
//		arraySound.add(touch_bomb_sound);
		arraySound.add(end_game_sound);
		
	}
	
	private void initMusic(){
		play_music = Gdx.audio.newMusic(Gdx.files.internal("sound/music.mp3"));
	}
	
	public void playSound(int iSound){
		arraySound.get(iSound).stop();
		arraySound.get(iSound).play();
	}
	
	public void playMusic(){
		play_music.stop();
		play_music.setLooping(true);
		play_music.play();
	}
	
	public void resetAllSound(){
		for(int i = 0; i < arraySound.size(); i ++){
			arraySound.get(i).stop();
		}
	}
	
	public void resetAllMusic(){
		play_music.stop();
	}
}
